home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDXPCH / CMDBLK.S < prev    next >
Encoding:
Text File  |  2001-02-09  |  5.5 KB  |  209 lines

  1.  
  2. .include    "defs.h"
  3.  
  4. .extern    _doscmd        ; do a simple command.  No DMA involved.
  5. .extern    _dorcmd        ; do a receive command.  DMA data back.
  6. .extern    _dowcmd        ; do a write command.  DMA data away.
  7.  
  8.  
  9. ;+
  10. ; OPCODES for standard SCSI and ACSI commands
  11. ;-
  12. TSTUNT    equ    $00
  13. RZUNT    equ    $01
  14. RQSEN    equ    $03
  15. FMTUNT    equ    $04
  16. RABLK    equ    $07
  17. READ    equ    $08
  18. WRITE    equ    $0a
  19. SEEK    equ    $0b
  20. INQRY    equ    $12
  21. MDSEL    equ    $15
  22. RLEAS    equ    $17
  23. MDSEN    equ    $1a
  24. STUNIT    equ    $1b
  25. RDIAG    equ    $1c
  26. SDIAG    equ    $1d
  27. RMEDIA    equ    $1e
  28. RDCAP    equ    $25        ; SCSI only
  29. XREAD    equ    $28        ; SCSI only
  30. XWRT    equ    $2a        ; SCSI only
  31. XSEEK    equ    $2b        ; SCSI only
  32. VERIFY    equ    $2f        ; SCSI only
  33. RDDFCT    equ    $37        ; SCSI only
  34. WRTBUF    equ    $3b        ; SCSI only
  35. RDBUF    equ    $3c        ; SCSI only
  36.  
  37. ;+
  38. ; EQUATES
  39. ;-
  40. NCMD        equ    6    ; normal command length (6 bytes)
  41. LCMD        equ    10    ; extended command length (10 bytes)
  42.  
  43. ;+
  44. ; DECLARATIONS
  45. ;-
  46.         .globl    _cmdblk
  47. _cmdblk:    dcb.b    10,0    ; command block
  48. .even
  49.  
  50.  
  51.  
  52. ;+
  53. ; rqsense() - set up and send command block of the REQUEST SENSE command.
  54. ;          (only the lsb of len is used)
  55. ;
  56. ; rqsense(pdev, len, buf)
  57. ; WORD    pdev;        $4(sp).w    ; physical unit number
  58. ; WORD    len;        $6(sp).w    ; amount of sense data (in bytes)
  59. ; BYTE    *buf;        $8(sp).l    ; buffer for sense data
  60. ;-
  61.     .globl    _rqsense
  62. _rqsense:
  63.     bsr    clrcmdblk        ; clear command block
  64.     lea    _cmdblk,a0        ; a0 -> beginning of command block
  65.     move.b    #RQSEN,(a0)        ; byte 0 = RQSEN opcode
  66.     move.b    $7(sp),4(a0)        ; byte 4 = allocation length 
  67.                     ; byte 1-3 and 5 = reserved
  68.     moveq    #4,d1            ; request at least 4 bytes
  69.     cmp.w    $6(sp),d1        ; requesting < 4 bytes?
  70.     bcc.s    .0            ; if so, request 4 bytes
  71.     move.w    $6(sp),d1        ; else d1 = requested len (in #bytes)
  72. .0:    move.w    $4(sp),d0        ; d0 = physical unit number
  73.     moveq    #NCMD,d2        ; d2 = length of command
  74.     movea.l    $8(sp),a0        ; a0 = buffer for sense data
  75.     bsr    _dorcmd            ; send the command
  76.     rts
  77.  
  78.  
  79.  
  80. ;+
  81. ; hread() - set up and send command block of the READ command.
  82. ;
  83. ; hread(sectnum, count, buf, pdev)
  84. ; LONG    sectnum        4(sp).l
  85. ; WORD    count        8(sp).w
  86. ; BYTE    *buf;        $a(sp).l    $b(sp)=high $c(sp)=mid $d(sp)=low
  87. ; WORD    pdev;        $e(sp).w
  88. ;-
  89.     .globl    _hread
  90. _hread:    lea    _cmdblk,a0        ; a0 -> beginning of command block
  91.     move.b    #READ,(a0)+        ; byte 0 = READ opcode
  92.     move.b    5(sp),(a0)+        ; byte 1 = msb of logical block addr
  93.     move.b    6(sp),(a0)+        ; byte 2 = logical block addr
  94.     move.b    7(sp),(a0)+        ; byte 3 = lsb of logical block addr
  95.     move.b    9(sp),(a0)+        ; byte 4 = transfer length (in blocks)
  96.     clr.b    (a0)            ; byte 5 = control byte
  97.     move.w    $e(sp),d0        ; d0 = physical unit number
  98.     moveq    #0,d1            ; clear d1
  99.     move.w    8(sp),d1        ; d1 = transfer length (in bytes)
  100.     lsl.l    #8,d1            ;    = # blocks * 512
  101.     add.l    d1,d1
  102.     moveq    #NCMD,d2        ; d2 = length of command
  103.     movea.l    $a(sp),a0        ; a0 = read buffer
  104.     bsr    _dorcmd            ; send the command
  105.     rts
  106.  
  107.  
  108. ;+
  109. ; hwrite() - set up and send command block of the WRITEcommand.
  110. ;
  111. ; hwrite(sectnum, count, buf, pdev)
  112. ; LONG    sectnum        4(sp).l
  113. ; WORD    count        8(sp).w
  114. ; BYTE    *buf;        $a(sp).l    $b(sp)=high $c(sp)=mid $d(sp)=low
  115. ; WORD    pdev;        $e(sp).w
  116. ;-
  117.     .globl    _hwrite
  118. _hwrite:
  119.     lea    _cmdblk,a0        ; a0 -> beginning of command block
  120.     move.b    #WRITE,(a0)+        ; it's a read; byte 0 = READ opcode
  121.     move.b    5(sp),(a0)+        ; byte 1 = msb of logical block addr
  122.     move.b    6(sp),(a0)+        ; byte 2 = logical block addr
  123.     move.b    7(sp),(a0)+        ; byte 3 = lsb of logical block addr
  124.     move.b    9(sp),(a0)+        ; byte 4 = transfer length (in blocks)
  125.     clr.b    (a0)            ; byte 5 = control byte
  126.     move.w    $e(sp),d0        ; d0 = physical unit number
  127.     moveq    #0,d1            ; clear d1
  128.     move.w    8(sp),d1        ; d1 = transfer length (in bytes)
  129.     lsl.l    #8,d1
  130.     add.l    d1,d1
  131.     moveq    #NCMD,d2        ; d2 = length of command
  132.     movea.l    $a(sp),a0        ; a0 = write buffer
  133.     bsr    _dowcmd            ; send the command
  134.     rts
  135.  
  136.  
  137. ;+
  138. ; inquiry() - set up and send command block of the INQUIRY command.
  139. ;
  140. ; inquiry(pdev, len, buf)
  141. ; WORD    pdev;        $4(sp).w    ; physical unit number
  142. ; WORD    len;        $6(sp).w    ; amount requested (in bytes)
  143. ; BYTE    *buf;        $8(sp).l    ; buffer for inquiry data
  144. ;-
  145.     .globl    _inquiry
  146. _inquiry:
  147.     bsr    clrcmdblk        ; clear command block
  148.     lea    _cmdblk,a0        ; a0 -> beginning of command block
  149.     move.b    #INQRY,(a0)        ; byte 0 = INQRY opcode
  150.     move.b    $7(sp),4(a0)        ; byte 4 = allocation length 
  151.                     ; byte 1-3 and 5 = reserved
  152.     move.w    $4(sp),d0        ; d0 = physical unit number
  153.     moveq    #0,d1            ; clear d1
  154.     move.w    $6(sp),d1        ; d1.l = transfer length (in bytes)
  155.     moveq    #NCMD,d2        ; d2 = length of command
  156.     movea.l    $8(sp),a0        ; a0 = buffer for sense data
  157.     bsr    _dorcmd            ; send the command
  158.     rts
  159.  
  160.  
  161. .if    !DRIVER                ; not to be included in driver
  162.  
  163.  
  164.  
  165. ;+
  166. ; readcap() - set up and send command block of the EXTENDED READ command.
  167. ;
  168. ; readcap(pdev, pmi, sectnum, buf)
  169. ; WORD    pdev;        4(sp).w
  170. ; WORD    pmi;        6(sp).w        (only low byte is used)
  171. ; LONG    sectnum;    8(sp).l
  172. ; BYTE    *buf;        $c(sp).l    $d(sp)=high $e(sp)=mid $f(sp)=low
  173. ;-
  174.     .globl    _readcap
  175. _readcap:
  176.     lea    _cmdblk,a0        ; a0 -> beginning of command block
  177.     move.b    #RDCAP,(a0)+        ; byte 0 = RDCAP opcode
  178.     clr.b    (a0)+            ; byte 1 = log unit # + reserved
  179.     move.l    8(sp),(a0)+        ; byte 2-5 = logical block addr
  180.     clr.b    (a0)+            ; byte 6 = reserved
  181.     clr.b    (a0)+            ; byte 7 = reserved
  182.     move.b    7(sp),(a0)+        ; byte 8 = partial medium indicator
  183.     clr.b    (a0)            ; byte 9 = reserved
  184.     move.w    $4(sp),d0        ; d0 = physical unit number
  185.     moveq    #8,d1            ; d1 = transfer length (in bytes)
  186.     moveq    #LCMD,d2        ; d2 = length of command
  187.     movea.l    $c(sp),a0        ; a0 = data buffer
  188.     bsr    _dorcmd            ; send the command
  189.     rts
  190.  
  191. .endif    ;!DRIVER
  192.  
  193.  
  194.  
  195. ;+
  196. ; clrcmdblk()
  197. ;
  198. ; Clear the 10-byte command block
  199. ;-
  200. clrcmdblk:
  201.     lea    _cmdblk,a0        ; a0 = ptr to command block
  202.     clr.l    (a0)+
  203.     clr.l    (a0)+
  204.     clr.w    (a0)
  205.     rts
  206.  
  207.  
  208.  
  209.